/**
 * @Author: easten
 * @Created: 2024-07-31 23:40:20
 * @Description: 设备物模型、传感器相关
 *
 *
 */

import { IotSensorGroup } from "_common/entity";
import { createRequest, RequestMethod } from "_common/request";
import { AxiosInstance } from "axios";

export class ApiSensorGroup {
  /**
   * @description 请求实例
   * @type {RequestMethod}
   * @memberof ApiDevice
   * */
  request: RequestMethod;
  url: string = "api/iot/sensor-group/";

  /**
   * @description 构造函数
   * @param config axios 配置
   */
  public constructor(instance: AxiosInstance) {
    // axios 实例化
    this.request = createRequest(instance);
  }

  /** 创建属性 */
  createSensorGroup(data: IotSensorGroup) {
    return this.request.post<boolean>(this.url, data);
  }

  /** 更新属性 */
  updateSensorGroup(data: IotSensorGroup) {
    return this.request.put<boolean>(this.url, data);
  }

  /** 删除属性 */
  deleteSensorGroup(id: number) {
    return this.request.delete<boolean>(this.url + id);
  }

  /** 获取属性信息 */
  getSensorGroupInfo(id: number) {
    return this.request.get<IotSensorGroup>(this.url + "get-attr", { id });
  }

  /** 获取属性列表 */
  getSensorGroupList() {
    return this.request.get<IotSensorGroup[]>(this.url + "get-list");
  }

  // 获取属性分页列表
  getPageList(params: any) {
    return this.request.get<any>(this.url + "get-page", params);
  }
}
